<!-- 加分项 -->
<template>
  <div class="page_padding">
    <MyNavBar @goback="goback" :title="title" />
    <div class="tabs_box" v-if="bonusType == '2'">
      <van-tabs
        @click="onTabsClick"
        color="#d80a06"
        line-width="15"
        line-height="2"
        border
        swipeable
        title-active-color="#d80a06"
        title-inactive-color="#333333"
        v-model="tabsActive"
        :sticky="true">
        <van-tab title="录入" title-class="my_tab"></van-tab>
        <van-tab title="审定" title-class="my_tab"></van-tab>
      </van-tabs>
    </div>
    <BonusOne v-if="tabsActive == 0 || bonusType == '1'" bonusType="1" :addType="addType" />
    <BonusTwo v-else-if="tabsActive == 1" bonusType="2" />
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import MyNavBar from '@com/MyNavBar'
import BonusOne from './BonusOne'
import BonusTwo from './BonusTwo'
export default {
  components: {
    MyNavBar,
    BonusOne,
    BonusTwo,
  },
  data() {
    return {
      title: '加分项',
      userInfo: JSON.parse(localStorage.userInfo),
      tabsActive: 0,

      bonusType: '1',
      addType: '1',
    }
  },
  watch: {},
  computed: {
    ...mapGetters('role', ['isOtherRole', 'isNormalRole', 'isAdminRole', 'isMainRole', 'isOrgRole', 'isPartRole']),
  },
  created() {},
  mounted() {
    if (this.isOrgRole) {
      this.addType = '2' // 个人、部门申报
    } else if (this.isAdminRole) {
      this.bonusType = '2'
      const routeLength = this.$route.path.length
      if (this.$store.state.pageTab.substring(0, routeLength) === this.$route.path) {
        this.tabsActive = Number(this.$store.state.pageTab.substring(this.$route.path.length))
      }
    }
  },
  methods: {
    goback() {
      this.$router.go(-1)
    },
    onTabsClick(name, title) {
      this.$store.state.pageTab = this.$route.path + this.tabsActive
    },
  },
}
</script>

<style lang="scss" scoped>
.page_padding {
  .tabs_box {
    top: 48px;
    left: 0;
    width: 100%;
    height: 40px;
    z-index: 10;
    /deep/.van-tabs--line .van-tabs__wrap {
      height: 40px;
      .my_tab {
        font-weight: bold;
      }
      .van-tab__text {
        font-size: 13px;
      }
    }
  }
}
</style>
